import { api } from '@/utils/request'
import type { Note, CreateNoteRequest, UpdateNoteRequest } from '@/types/note'

// 获取所有小纸条
export const getNotes = () => {
  return api.get<Note[]>('/notes')
}

// 获取收到的小纸条
export const getReceivedNotes = (userId: number) => {
  return api.get<Note[]>(`/notes/received/${userId}`)
}

// 获取发送的小纸条
export const getSentNotes = (userId: number) => {
  return api.get<Note[]>(`/notes/sent/${userId}`)
}

// 创建小纸条
export const createNote = (data: CreateNoteRequest) => {
  return api.post<Note>('/notes', data)
}

// 更新小纸条（标记已读）
export const updateNote = (id: number, data: UpdateNoteRequest) => {
  return api.put<Note>(`/notes/${id}`, data)
}

// 删除小纸条
export const deleteNote = (id: number) => {
  return api.delete(`/notes/${id}`)
}

// 获取已删除的小纸条（回收站）
export const getDeletedNotes = () => {
  return api.get<Note[]>('/notes/deleted')
}

// 恢复小纸条
export const restoreNote = (id: number) => {
  return api.put(`/notes/${id}/restore`)
}

// 永久删除小纸条
export const permanentDeleteNote = (id: number) => {
  return api.delete(`/notes/${id}/permanent`)
}
